﻿{% extends "base.html" %}


{% block css %}
	<link rel = "stylesheet" href = "/css/userspace.css" type = "text/css" />
{% endblock %}

{% block javascript %}
	<script type = "text/javascript" src = "/js/jquery-1.6.2.js">
	</script>
	
	<script type = "text/javascript" src = "/js/ajax_post.js">
	</script>
	<script type = "text/javascript">
		$(document).ready(function()
		{
			$(".delete").click(function()
			{
				var result = confirm("确定要删除这条微博吗？");
				if(result == false)
					return result;
				else
				{
					jQuery.post("/delete/", { delete_post_id: $(this).children().first().text() },
					function(data)
					{
						if(data != "删除成功")
							alert(data);
					});
					$(this).parent().parent().remove();
				}
					
				return false;
			});
			
			$("#follow_anchor").click(function()
			{
				$.post($("#follow_anchor").attr("href"),function(data)
				{
					//alert(data);
					if(data != '已关注')
						alert(data);
					else
					{
						$("#follow_anchor").text(data);
						$("#follow_anchor").css("background","url(\"/image/button-l.gif\")");
						$("#follow_anchor").removeAttr("href");
					}
					
				});
				return false;
			});
			
			$("#relation a").click(function()
			{
				return confirm("确定取消关注吗？");
			});
		});
	</script>
			
{% endblock %}



{% block title %}
Dlib-MicroBlog 首页
{% endblock %}

{% block navigationlist %}

	<ul>
		<li>
			<a href = "/home">首页</a>
		</li>
		<li>
			<a href = "/nick/{{ session_user.nick_name }}">我的空间</a>
		</li>
		
		<li>
			<a href = "/message">私信</a>
		</li>
		<li>
			<a href = "/finder">找人</a>
		</li>
		
		<li>
			<a href = "/browse">随便看看</a>
		</li>
		<li>
			<a href = "/search">搜索</a>
		</li>
		
		<li>
			<a href = "/settings">设置</a>
		</li>
		<li>
			<a href = "/logout">退出</a>
		</li>
		
	</ul>
	
{% endblock %}

{% block body %}
	<table id = "columns">
		<tr>
			<td id = "main">				
				<div id="info">					
					 <div id="avatar">
						<img src="/image/avatar.png" />
					 </div>				
					<div id="panel">
						<h1>{{ nick_name }}</h1>
						<p class = "actions">
						{% if same_user %}
						
						{% else %}
							{% if fans_or_not %}
							
							{% else %}
								<a id = "follow_anchor" href = "/follow/nick/{{ nick_name }}/" class = "post_act bh" >关注此人</a>
							{% endif %}
								<a href = "#" class = "bl">给TA留言</a>
								<a href = "/message/nick/{{ nick_name }}" class = "bl">发私信</a>
							
							{% if fans_or_not %}
								<p id = "relation">
									是我关注的人
									<span class = "actions">
										<a href = "/remove/nick/{{ nick_name }}/" class = "post_act">> 取消关注</a>
									</span>
								</p>
							{% endif %}
						{% endif %}
						</p>
					</div>					
				</div>
				<div id = "stream">
					<ol class = "dashtop">
						{% for blogpost in blogpost_list %}
							<li class = "unlight">
							
								<a href = "/nick/{{ blogpost.0.user.nick_name }}" class = "author">
									{{ blogpost.0.user.nick_name }}
								</a>
								<span class = "content">
									{{ blogpost.2|safe }}
								</span>
								<span class = "stamp">
									<a href = "/microblog/{{ blogpost.0.id }}">
									{{ blogpost.0.post_datetime|timesince }}前
									</a> &nbsp;通过网页
								</span>
							
							
								<span class = "op">
									{% if blogpost.1 %}
										<a href = "#" class = "delete"><span class = "deleteidspan">{{ blogpost.0.id }}</span></a>
									{% else %}
										<a href = "/home/reply/{{ blogpost.0.id }}" class = "reply">回复</a>
										<a href = "/home/forward/{{ blogpost.0.id }}" class = "forward">转发</a>
									{% endif %}
							
									</span>	
							</li>
					{% endfor %}
					
					</ol>
				</div>
					
			</td>
			<td id = "sidebar">
				<div id = "user_top">
				</div>
				
				<ul id = "reminder">
				</ul>
				
				<ul id = "user_stats">
					<li>
						<a href = "/follower">
							<span class = "count">{{ follower_count}}</span>
							<span class = "label">他关注的人</span>
						</a>
					</li>
					<li>
						<a href = "/followee">
							<span class = "count">{{ fans_count }}</span>
							<span class = "label">关注他的人</span>
						</a>
					</li>
					<li>
						<a href = "/nick/{{ session_user.nick_name }}">
							<span class = "count">{{ blog_count }}</span>
							<span class = "label">微博</span>
						</a>
					</li>
				</ul>
				
				<div class = "stabs" id = "navtabs">
					<ul>
						<li class ="current">
							<a href = "/nick/{{ nick_name }}">
								<span class = "label">微博({{ blog_count }})
								</span>
							</a>
						</li>
						<li>
							<a href = "/collection/">
								<span class = "label">收藏(0)
								</span>
							</a>
						</li>
						<li>
							<a href = "/photos/">
								<span class = "label">照片(0)
								</span>
							</a>
						</li>
						
					</ul>
				</div>
				
				<div id = "search_bar">
					<form action = "/search" method = "post">
						<input type = "text" id = "search_input"  />
						<input type = "submit" id = "search_button" value = "搜索"/>
					</form>
				</div>
		
			</td>
		</tr>
	</table>
{% endblock %}
